package kr.hkit.myframework.uicomp;

import java.awt.GridLayout;

import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingConstants;

public class InputCmbPanel extends JPanel {
	private static final long serialVersionUID = 1L;
	
	private JLabel lbl;
	private JComboBox<Object> cmb;
	
	public InputCmbPanel() {
		initialize();
	}
	
	public InputCmbPanel(String title){
		initialize();
		lbl.setText(title);
	}
	
	private void initialize() {
		setLayout(new GridLayout(0, 2, 0, 0));
		
		lbl = new JLabel();
		lbl.setHorizontalAlignment(SwingConstants.CENTER);
		add(lbl);
		
		cmb = new JComboBox<>();
		add(cmb);
	}

	public void setLbl(String title) {
		this.lbl.setText(title);
	}
	
	public String getSelectItem(){
		return (String) cmb.getSelectedItem();
	}
	
	public void setDefaultSelectIndex(int idx){
		cmb.setSelectedIndex(idx);
	}
	
	public void setSelectItem(String str){
		cmb.setSelectedItem(str);
	}

	public void addItems(String...lists){
		for(String item:lists){
			cmb.addItem(item);
		}
	}

}
